import waflib.Task, waflib.TaskGen
from waflib.TaskGen import extension, extension

def create_simple_protoc_task(name, ext, compiled_ext, type, before, shell = True, color = 'PINK', proto_file = '../proto/particle/particle_ddf.proto'):
    def create(self, node):
        task = self.create_task(name)
        task.set_inputs(node)
        out = node.change_ext(compiled_ext)
        task.set_outputs(out)

    cmd = 'protoc --encode=%s -I ../proto/particle -I ${DYNAMO_HOME}/share/proto -I ${DYNAMO_HOME}/ext/include %s < ${SRC} > ${TGT}' % (type, proto_file)
    waflib.Task.task_factory(name, cmd, before=before, shell=shell, color=color)
    extension(ext)(create)
create_simple_protoc_task('particle_fx', '.particlefx', '.particlefxc', 'dmParticleDDF.ParticleFX', before='c cxx')

def build(bld):
    test_particle = bld(features = 'c cxx cprogram test',
                        includes = '. .. ../../proto',
                        use = 'TESTMAIN DDF DLIB PLATFORM_NULL GRAPHICS_NULL PROFILE_NULL SOCKET PLATFORM_THREAD particle',
                        proto_gen_py = True,
                        source = bld.path.ant_glob(['*.particlefx', '*.cpp']),
                        target = 'test_particle')

    test_particle.install_path = None
